package com.red.wine.webservice;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

import android.os.Message;
import android.util.Log;

import com.google.json.Gson;
import com.google.json.JsonSyntaxException;
import com.google.json.stream.JsonReader;

public class ServiceHelper extends BaseService {
	private static final String TAG = "ServiceHelper";
	private static ServiceHelper instance = null;
	private Gson gson;

	public static synchronized ServiceHelper getInstance() {
		if (instance == null) {
			instance = new ServiceHelper();
		}

		return instance;
	}

	private ServiceHelper(){
		if (gson == null) {
			gson = new Gson();
		}
	}

	public <T> T postData(String url, String postString, Class<T> cls)
			throws JsonSyntaxException, AssertionError, IOException {
		if(gson == null){
			gson = new Gson();
		}
		return (T) gson.fromJson(postOnService(url, postString), cls);
	}

}
